package com.trace.app.controller;


import com.trace.app.entity.ResponseResult;
import com.trace.app.service.RecordService;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import com.trace.app.entity.Record;

/**
 * (Record)表控制层
 *
 * @author lionkliu
 * @since 2024-03-17 15:55:23
 */
@RestController
@RequestMapping("record")
public class RecordController {

    @Resource
    private RecordService recordService;

    @GetMapping("/page")
    public ResponseResult selectPage(@RequestParam("pageNum") Integer pageNum,
                                     @RequestParam("pageSize") Integer pageSize) {
        return recordService.selectPage(pageNum, pageSize);
    }

    @GetMapping("{proId}")
    public ResponseResult getRecordsByProId(@PathVariable Integer proId) {
        return recordService.getRecordsByProId(proId);
    }

    @PostMapping
    public ResponseResult insert(@RequestBody Record record) {
        return recordService.insertOne(record);
    }

    @PutMapping
    public ResponseResult update(@RequestBody Record record) {
        return recordService.updateOne(record);
    }

    @DeleteMapping("/{id}")
    public ResponseResult delete(@PathVariable Integer id) {
        return recordService.deleteById(id);
    }

}
